let astNodeTags = require('../common/ast-node-tags');
let expressionCommandGenerator = require('./expression-command-generator');
let operatorCommandGenerator = require('./operator-command-generator');

let commandGenerator = {
  result: [],
  generate(nodes) {
    nodes.forEach(node => {
      let result = {};
      if (node.tag == astNodeTags.OPERA) {
        result = operatorCommandGenerator.generate(node);
      } else if ([astNodeTags.DIGIT, astNodeTags.DOT, astNodeTags.DOLLOR].includes(node.tag)) {
        result = operatorCommandGenerator.generate(node);
      } else {
        result = expressionCommandGenerator.generate(node);
      }
      this.result.push(result);
    });
    return this.result;
  }
};

module.exports = commandGenerator;
